home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / MATHS / ARCAUT / Automatons / Life < prev    next >
Text File  |  1991-07-27  |  2KB  |  70 lines

  1. AUTOMATON*
  2.  
  3.   Life
  4.  
  5.   This must be the most well known of all Cellular Automatons, originally
  6.   devised by John Horton Conway. It is a two state Moore neighbourhood
  7.   automaton; the two states are called dead & alive. The rules governing
  8.   growth are: If a living cell has two or three living neighbours, it remains
  9.   alive, otherwise it is considered to be overcrowded or undernourished &
  10.   dies. If a dead cell has exactly three living neighbours, a live cell will
  11.   be born, otherwise it remains dead. 'Life' supports much complexity & is
  12.   actually equivalent to a Turing machine (it could be used to solve any
  13.   computable problem - like wireworld & BBM). This implementation selects one
  14.   of two initial configurations, one of which is known as a Glider Gun; a
  15.   prize had been offered & was won for the discovery of this object. Try a
  16.   40x30 window to view the gun.
  17.  
  18. INITIALISATION*
  19.  
  20.   10DEF PROCdo
  21.   20*SetEval wrap off
  22.   30*SetEval border dead
  23.   40ENDPROC
  24.   
  25. SCREEN*
  26.  
  27.   10DEF PROCdo
  28.   20DIM buf% 256:SYS "OS_ReadVarVal","alive",buf%,256:c%=FNacol(!buf%)
  29.   30GCOL c% AND 63 TINT c%
  30.   40CASE RND(2) OF
  31.   50WHEN 1
  32.   60MOVE-8,0:DRAW BY 19,0:DRAW BY 0,-4
  33.   70MOVE BY -19,-4:DRAW BY 0,0
  34.   80WHEN 2
  35.   90LOCAL DATA
  36.  100RESTORE+ 0
  37.  110DATA 123456789#
  38.  120DATA 123456789##
  39.  130DATA 1234##789A##
  40.  140DATA ##34##789A###
  41.  150DATA ##34##789A##
  42.  160DATA 123456789##
  43.  170DATA 123456789#
  44.  180DATA #
  45.  190DATA #2#
  46.  200DATA 1#2#
  47.  210DATA 1#23#567##
  48.  220DATA 1#2#4567##
  49.  230DATA #2#
  50.  240DATA #
  51.  250FOR q%=16 TO -8 STEP -4:READ q$
  52.  260FOR w%=1 TO LEN q$:IF MID$(q$,w%,1)="#" POINT 4*w%-76,q%
  53.  270NEXT:NEXT
  54.  280FOR q%=8 TO -16 STEP -4:READ q$
  55.  290FOR w%=1 TO LEN q$:IF MID$(q$,w%,1)="#" POINT 4*w%+28,q%
  56.  300NEXT:NEXT
  57.  310ENDCASE
  58.  320ENDPROC
  59.  
  60. CODE*
  61.  
  62. ( READ_NEIG
  63.   alive SCOUNT_NEIG
  64.   CELL   IF ( DUP 2 = IF (alive ==)
  65.                   3 = IF (alive ==)
  66.                            dead == )
  67.        ELSE (     3 = IF (alive ==)
  68.                     ELSE ( dead ==)) )
  69.  
  70. END*